
package com.fly.datasyn.entity;

import java.util.Date;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;

import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fly.core.entity.Idable;
import com.vladmihalcea.hibernate.type.json.JsonStringType;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@Entity
@Table(name = "health")
@ApiModel(description = "健康和业务数据对象")
@TypeDef(name = "json", typeClass = JsonStringType.class)
public class Health implements Idable<Long>
{
    @ApiModelProperty(hidden = true)
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;
    
    /**
     * 平安校园平台，记录编号
     */
    @ApiModelProperty(value = "平安校园平台，记录编号", required = true)
    @NotBlank(message = "healthdataid不能为空")
    @Column(name = "healthDataId", nullable = false, length = 255)
    private String healthDataId;
    
    /**
     * 终端标识，比如终端序列号、IMEI等
     */
    @ApiModelProperty(value = "终端标识，比如终端序列号、IMEI等", required = true)
    @NotBlank(message = "code不能为空")
    @Column(name = "code", nullable = false, length = 255)
    private String code;
    
    /**
     * 终端运行信息
     */
    @ApiModelProperty(value = "终端运行信息, json数组", required = true)
    @NotEmpty(message = "operatingparameters不能为空")
    @Type(type = "json")
    @Column(columnDefinition = "operatingParameters", nullable = false)
    private Map<String, String> operatingParameters;
    
    /**
     * 数据类型 1.健康数据， 2.业务数据
     */
    @ApiModelProperty(value = "数据类型 1.健康数据， 2.业务数据", required = true)
    @NotBlank(message = "type不能为空")
    @Pattern(regexp = "1|2", message = "type取值1或2")
    @Column(name = "type", nullable = false, length = 255)
    private String type;
    
    /**
     * 实时数据产生时间
     */
    @ApiModelProperty(value = "实时数据产生时间 yyyy-MM-dd HH:mm:ss", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull(message = "engenderdate不能为空")
    @Past(message = "engenderDate必须小于当前时间")
    @Column(name = "engenderDate", nullable = false, length = 255)
    private Date engenderDate;
    
    /**
     * 平安校园平台实时数据接收时间
     */
    @ApiModelProperty(value = "平安校园平台实时数据接收时间 yyyy-MM-dd HH:mm:ss", required = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull(message = "receivedate不能为空")
    @Past(message = "receiveDate必须小于当前时间")
    @Column(name = "receiveDate", nullable = false, length = 255)
    private Date receiveDate;
    
    /**
     * 时间
     */
    @ApiModelProperty(hidden = true)
    @Column(name = "time", nullable = false, length = 255)
    private String time;
}
